package com.tmall.tmall.utils;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Utils {
    /**
     * 密码加密
     */
    public static String encryptPassword(String password) throws NoSuchAlgorithmException {
        return md5Encrypt(password).substring(8,24);
    }
    /**
     * 生成加密后的字符串
     */
    public static String md5Encrypt(String pw) throws NoSuchAlgorithmException {
        MessageDigest md= MessageDigest.getInstance("md5");
        md.update(pw.getBytes());
        String ans =new BigInteger(1,md.digest()).toString(16);
        return ans;
    }
}
